package com.amox.uitest.adapter;

import org.dom4j.Element;

import com.amox.uitest.common.KeyWord;
import com.amox.uitest.kit.LogKit;
import com.amox.uitest.tcase.BaseTestCase;

public class LogAdapter extends BaseAdapter<Boolean> {
	
	public LogAdapter(BaseTestCase uitest) {
		super(uitest);
	}
	
	@Override
	public Boolean adapter(Element element) throws Exception {
		String level = element.attributeValue(KeyWord.level.name());
		System.out.println("level = " + level);
		if(KeyWord.warn.name().equals(level)) {
			LogKit.warn(element.getStringValue());
			LogKit.printLog("[WARN] " + element.getStringValue());
			
		} else if(KeyWord.error.name().equals(level)) {
			LogKit.error(element.getStringValue());
			LogKit.printLog("[ERROR] " + element.getStringValue());
			
		} else {
			LogKit.info(element.getStringValue());
			LogKit.printLog("[INFO] " + element.getStringValue());
		}
		
		return true;
	}
}
